package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.Result;
import com.itheima.pojo.Order;
import com.itheima.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/order")
@Api(tags = "体检预约")
public class OrderController {
    @Autowired
    private OrderService orderService;
    /**
     * 根据预约id查询预约信息
     */
    @GetMapping("/findById")
    @ApiOperation("根据预约id查询预约信息")
    public Result findById(@RequestParam Integer id) {
        log.info("根据预约id查询预约信息");
        Order order = orderService.findById(id);
        return new Result(true, MessageConstant.GET_ORDERSETTING_SUCCESS,order);
    }
    /**
     * 体检预约
     */
    @PostMapping("/submitOrder")
    @ApiOperation("体检预约")
    public Result submitOrder(@RequestBody Order order) {
        log.info("体检预约");
        Integer id = orderService.submitOrder(order);
        return new Result(true, MessageConstant.ORDER_SUCCESS,id);
    }

}
